package demo3;


//Description:接口的实例
class Animal{
    protected String name;

    public Animal(String name) {
        this.name = name;
    }
}
interface IFlying{
    void fly();
}
interface IRunning{//接口表示具有某种特性
    void run();
}
interface ISwimming{
    void swim();
}
class Brid extends Animal implements IFlying{

    public Brid(String name) {
        super(name);
    }

    @Override
    public void fly() {
        System.out.println(this.name + "正在飞");
    }
}
class Duck extends Animal implements IRunning,ISwimming,IFlying{

    public Duck(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(this.name + "正在跑");
    }

    @Override
    public void swim() {
        System.out.println(this.name + "正在游泳");
    }

    @Override
    public void fly() {
        System.out.println(this.name + "正在飞");
    }
}
class Drog extends Animal implements IRunning,ISwimming{

    public Drog(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(this.name + "正在跑");
    }

    @Override
    public void swim() {
        System.out.println(this.name + "正在游泳");
    }
}
class Robot implements IRunning{
    public Robot() {
    }

    @Override
    public void run() {
        System.out.println( "机器人正在跑");
    }
}
public class Test4 {
    public static void running(IRunning iRunning){
        iRunning.run();
    }
    public static void swimming(ISwimming iSwimming){
        iSwimming.swim();
    }
    public static void flying(IFlying iFlying){
        iFlying.fly();
    }
    public static void main(String[] args) {
        running(new Drog("青蛙"));
        swimming(new Duck("鸭子"));
        flying(new Brid("小鸟"));
        running(new Robot());
    }
}
